<?php
require_once ($_SESSION ['pathway'] . "/commun/ouvre_base.php");

// ~ $link = mysql_connect($host, $user, $passwd) or die('Impossible de se connecter : ' . mysql_error());
mysql_select_db ( $db ) or die ( 'Impossible de s&#233;lectionner la base de donn&#233;es' );

$id = $_POST ['id'];
if (isset ( $_POST ['mdp'] )) {
	$mdp = $_POST ['mdp'];
}

$queryuser = "SELECT *
		FROM `users`
		WHERE `last_name` LIKE '$id';";
$resultuser = mysql_query ( $queryuser ) or die ( "Impossible de r&#233;cup&#233;rer la liste des users" . mysql_error () );
$pwd = array ();
while ( $line = mysql_fetch_row ( $resultuser ) ) {
	array_push ( $pwd, $line [1] );
}

$password = $pwd [0];
// echo "password clair :", $mdp;
$passwordsoumis = md5 ( $mdp );
// echo "passwordsoumis :" ,$passwordsoumis;
// echo "passwordbase :" ,$password;

if ($password == $passwordsoumis) {
	$authentification = 1;
} else {
	$authentification = 0;
}

?>
